package com.example.cybz.common.exception;

import com.example.cybz.common.result.ResultCodeEnum;

/**
 * 业务异常类（扩展）
 */
public class BusinessException extends RuntimeException  {
    private final ResultCodeEnum code;
    private final Object data;

    public BusinessException(ResultCodeEnum code, String message) {
        super(message);
        this.code = code;
        this.data = null;
    }

    public BusinessException(ResultCodeEnum code, String message, Object data) {
        super(message);
        this.code = code;
        this.data = data;
    }

    public BusinessException(ResultCodeEnum code) {
        super(code.getMessage());
        this.code = code;
        this.data = null;
    }

    public ResultCodeEnum getCode() {
        return code;
    }

    public Object getData() {
        return data;
    }
}

